/**
 * @description routes加载器
 */

export default function routesLoader (defaultRoutes = []) {
  let routes = [].concat(defaultRoutes);

  const files = require.context(
    "../router",
    false,
    /^(?!\.\/index\b).*\.js$/
  );

  files.keys().forEach(key => {
    const file = files(key);
    routes = routes.concat(file.default);
  });
  return routes;
}
